package com.gzz.orchid.context.application.base.convert;


import com.gzz.orchid.context.application.base.command.ConfigurationSaveCmd;
import com.gzz.orchid.context.application.base.pojo.ConfigurationDto;
import com.gzz.orchid.context.application.base.pojo.ConfigurationVo;
import com.gzz.orchid.context.infrastructure.definition.Status;
import com.gzz.orchid.context.infrastructure.persistence.entity.base.BaseConfigPo;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

/**
 * @author higmd
 */
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, imports = {Status.class})
public interface ConfigurationConverter {
    ConfigurationConverter INSTANCE = Mappers.getMapper(ConfigurationConverter.class);

    @Mappings({
            @Mapping(target = "status", expression = "java(Status.parse(po.getStatus()))"),
    })
    ConfigurationVo mapVo(BaseConfigPo po);

    @Mappings({
            @Mapping(target = "status", expression = "java(Status.parse(po.getStatus()))"),
    })
    ConfigurationDto mapDto(BaseConfigPo po);

    void updatePo(@MappingTarget BaseConfigPo po, ConfigurationSaveCmd cmd);
}
